using UnityEngine;
using QFramework;

namespace QFramework.Monk
{
	public partial class EnemySpider : EnemyNormal
	{
		private bool mUpOrDown = false;
		protected override void Move()
		{
			if (!AppStart.CheckGameState(GameState.GamePlaying))
			{
				return;
			}

			// 空指针检查
			if (Player.Default != null)
			{
				mCurTime += Time.deltaTime;
				if (mCurTime>1.5f)
				{
					mCurTime = 0;
					mUpOrDown = !mUpOrDown;
				}
				// 方向 做上下弹跳运动
				var dir = (Player.Default.transform.position - this.transform.position).normalized ;
				var dirY = mUpOrDown ? 1 : -1;
				selfRigidbody2D.velocity =  (dir + dirY * Vector3.up) * mSpeed;;
			}
			else
			{
				selfRigidbody2D.velocity = Vector2.zero;
			}
		}
	}
}
